#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 1e5 + 10, INF = 0x3f3f3f3f;

int n, m;
vector<int> g[N];

struct tree
{
    int v[N];
    int lowbit(int x) { return x & -x; }
    void add(int x, int y) {
        for (; x <= n; x += lowbit(x))
            v[x] += y;
    }
    int ask(int x) {
        int ret = 0;
        for (; x; x -= lowbit(x))
            ret += v[x];
        return ret;
    }
} tr;

void add(int l, int r) { tr.add(l, 1);tr.add(r + 1, -1); }
int ask(int x) { return tr.ask(x); }

int fa[N], son[N], dep[N], siz[N];
int top[N], dfn[N], seg[N], cntd = 0;
void dfs1(int x, int f)
{
    fa[x] = f;
    dep[x] = dep[f] + 1;
    siz[x] = 1, son[x] = 0;
    int min_son = -1;
    for (auto y : g[x]) {
        if (y == f) continue;
        dfs1(y, x);
        siz[x] += siz[y];
        if (min_son < siz[y]) son[x] = y, min_son = siz[y];
    }
}
void dfs2(int x, int t)
{
    top[x] = t;
    dfn[x] = ++cntd;
    seg[cntd] = x;
    if (son[x] == 0) return;
    dfs2(son[x], t);
    for (auto y : g[x]) {
        if (y == fa[x] || y == son[x]) continue;
        dfs2(y, y);
    }
}

void modify(int x, int y)
{
    while (top[x] != top[y]) {
        if (dep[top[x]] < dep[top[y]]) swap(x, y);
        add(dfn[top[x]], dfn[x]);
        x = fa[top[x]];
    }
    if (dep[x] > dep[y]) swap(x, y);
    if (x != y) add(dfn[x] + 1, dfn[y]);
}

int query(int x, int y) { return ask(max(dfn[x], dfn[y])); }

void solve()
{
    cin >> n >> m;
    for (int i = 1;i < n;i++) {
        int x, y;cin >> x >> y;
        g[x].push_back(y);g[y].push_back(x);
    }
    dfs1(1, 0);dfs2(1, 1);
    while (m--) {
        char op;int x, y;cin >> op >> x >> y;
        if (op == 'P') {
            modify(x, y);
        } else {
            cout << query(x, y) << '\n';
        }
    }
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"(4 6
1 4
2 4
3 4
P 2 3
P 1 3
Q 3 4
P 1 4
Q 2 4
Q 1 4
)");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}